#include<iostream>
#include<cmath>
using namespace std;
int func1(int x);
int func2(int x);
int avg(int(*f)(int),int x1,int x2);
int a,b,c;
int m;

int main(){ 
    cin>>a>>b>>c;   
    cin>>m;
    int up,down;
    cin>>down>>up;
    int x1 = avg(func1,down,up);
    int x2 = avg(func2,down,up);
    cout<<x1<<endl;
    cout<<x2<<endl;
}

int avg(int(*f)(int),int x1,int x2){
    int sum=0;
    for(int i=x1;i<=x2;i++){
        sum += (*f)(i);
    }
    return sum/(x2-x1+1);
}

int func1(int x){
    return a*pow(x,2)+b*x+c;
}

int func2(int x){
    return pow(x,m);
}
